<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //全局作用域
        var num = 20;            //全局变量
        function fun(){
            //局部作用域
            var num = 10;        //局部变量
            console.log(num);    //输出局部变量值
        }
        fun();
        console.log(num);        //输出全局变量值
    </script>
</head>
<body>

</body>
</html>